package stream;

import java.util.*;
import java.util.stream.Stream;

public class Demo2 {
    public static void main(String[] args) {
        //单列集合
        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list, "a", "b", "c");
        list.stream().forEach(s -> System.out.println(s));
        //双列集合
        Map<String, String> map = new HashMap<>();
        map.put("a", "aa");
        map.put("b", "bb");
        map.put("c", "cc");
        //使用keyset 或 entry 对象
        map.keySet().stream().forEach(s -> System.out.println(s));
        map.entrySet().stream().forEach(s -> System.out.println(s));
        //数组
        int[] arr = {1, 2, 3};
        Arrays.stream(arr).forEach(s-> System.out.println(s));
        //零散数据使用Stream.of
        Stream.of(1,2,3).forEach(s-> System.out.println(s));
        Stream.of("a","b","c").forEach(s-> System.out.println(s));
        //这里只能使用引用数据类型,基本数据类型对象只会将整个数据传输给stream
        Stream.of(arr).forEach(s-> System.out.println(s));


    }
}
